<!DOCTYPE html>
<html>

	<head>
		<!--申明当前页面的编码集-->
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<!--网页标题-->
		<title>6.18年终理财狂欢</title>
		<!--适配当前屏幕-->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<!--iphone中safari私有meta标签,
        允许全屏模式浏览,隐藏浏览器导航栏-->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!--iphone中safari顶端的状态条的样式black(黑色)-->
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta content="telephone=no" name="format-detection">
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<link rel="stylesheet" type="text/css" href="js/layer/build/mobile/need/layer.css"/>
	</head>

	<body>
		<div class="content">
			<div>
				<img src="img/banner.png" alt="" />
				<img class="imgzs" src="img/zs_zw.png" alt="" />
			</div>
			<div class="pageBox">
				<div class="actTime">
					<div>
						<img src="img/yuandian.png" alt="" />
					</div>
					<div>
						<ul style="float: right;width: 45%;">
							<li>
								<span><span class="conducting nostarted">未开始</span>抽奖大转盘</span>
							</li>
							<li>
								6月20日-6月22日
							</li>
						</ul>
						<ul style="">
							<li>
								<span><span class="conducting nostarted">未开始</span>全场加薪1.8%</span>
							</li>
							<li>
								6月15日-6月19日
							</li>
						</ul>
					</div>
				</div>

				<div class="" id="luckDraw">
					<div>
						<img style="width: 65px;height: auto;float: right;margin-top: 34px;margin-right: 20px;" src="img/zs.png" alt="" />
						<img style="width: 55px;height: auto;margin-left: 20px;" src="img/rw.png" />
					</div>
					<div class="luckDrawBox">
						<img style="" src="img/dzpcj.png" alt="" />
						<div class="luckDraw">
							<!--中奖显示-->
							<div class="winningList" id="wrapper">
								<p class="innerp" id="CText"></p>
							</div>
							<div class="luckDrawTimes">
								<p>您有<span>0</span>次抽奖机会</p>
							</div>
							<div class="zpGroup">
								<div class="luckDrawZp">
									<img id="luckTurntable" src="img/zp.png" />
								</div>
								<div class="luckDrawBtn">
									<img id="start" src="img/cjwks.png" />
								</div>
							</div>
							<div class="btnGroup">
								<div>
									<img onclick="myPrize()" src="img/myjp.png" />
								</div>
								<div>
									<img onclick="rewardExplain()" src="img/jlsm.png" />
								</div>
							</div>
							<div>
								<img src="img/hdsm_03.png" />
							</div>
							<div style="padding: 5% 20%;">
								<img class="ljtz" src="img/ljtz.png" onclick="wv.go(1)" alt="" />
							</div>
						</div>

					</div>
				</div>
				<p style="text-align: center;font-size: 0.6rem;color: #ad74c3;margin: 2% 0 3% 0;">赚啦在法律范围内保留对本次活动的解释权。</p>
			</div>
		</div>
		<div class="rewardBox rewardB">
			<img style="width: 78.4%;margin-top: 38%;" src="img/jssm_d.png" alt="" /><br />
			<img style="width: 10.13%;margin-top: 5%;" src="img/close.png" />
		</div>
		<div class="myPrize rewardBox">
			<div class="bg1">
				<div class="bg2">
					<h2 style=""><img src="img/title.png"/></h2>
					<div class="kong" style="display: none;">
						<div style="width: 60%;margin: 6% auto;">
							<img src="img/kong.png" />
						</div>
						<p style="font-size: 0.7rem;">暂无中奖纪录</p>
						<p style="font-size: 0.65rem;">你离大奖只差一步，快去获得机会抽取奖品吧~</p>
					</div>
					<div class="zjjl">
						<table>
							<!--<tr>
								<td class="zjbtn"><span>奖品</span></td>
								<td class="zjbtn"><span>数量</span></td>
							</tr>-->
							<!--<tr>
								<td>3000元京东卡</td>
								<td>1</td>
							</tr>-->
						</table>
					</div>
				</div>
			</div>
			<div class="Dclose" style="text-align: center;">
				<img style="width: 10.13%;margin-top: 5%;display: inline-block;" src="img/close.png" />
			</div>
		</div>
		<div class="zjBox rewardBox">
			<div>
				<div class="rewardPic">
					<img src="img/xjhb_58.png" alt="" />
				</div>
				<div class="textBtn" style="font-family: simhei;margin-top: 6%;">
					<p style="color: #9c2024;font-size: 0.75rem;margin-bottom: 2%;">恭喜！您获得了</p>
					<span style="color: #ff5706;font-size: 1rem;">58元现金红包</span>
					<p class="pTitle" style="color: #d26d1c;font-size: 0.7rem;margin: 5% 0;">请在[资产-我的优惠券]中查看</p>
					<button type="button">我知道了</button>
				</div>
			</div>
		</div>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/layer/build/mobile/layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/awardRotate.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/MD5.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var times="";
			var useCode = "2017101917285439312569";
			
			$(function() {
				times=getTime();
//				try{
//					useCode=wv.getid();
//					wv.rightShow(false)
//				}catch(e){
//					layer.open({
//						content: "获取userCode失败",
//						skin: 'msg',
//						time: 2,
//					})
//				}
				luckDraw.init();
				
				if(times >= 20180620){
					wrap();
				}
			});
			//抽奖功能
			var luckDraw={
				priceList:null,
				$btn:$("#luckTurntable"), // 旋转的图片
				isture:0,//是否正在抽奖
				playnum:0,//初始次数，由后台传入
				getPlaynum:function(){
					var that=this;
					var data="";
					getData({
						"url":location.origin + "/LuckSys",
						"code":"190200"
					},function(datas){
						var list=datas.prizeList;
							that.playnum=datas.remainChance;
							that.priceList=list;
						$(".luckDrawTimes p span").html(that.playnum);
						layoutInit();
					})
				},	    
				clickfunc:function(data,obj){
					switch(data) {
						case obj[0].id:
							this.rotateFunc(obj[0].id, 0, {"title":"3000元京东卡","goods":true,"src":"img/jp_jdk.png"});
							break;
						case obj[1].id:
							this.rotateFunc(obj[1].id, 288,{"title":"Luna mini2","goods":true,"src":"img/jp_luna.png"});
							break;
						case obj[2].id:
							this.rotateFunc(obj[2].id, 72, {"title":"格力无叶风扇","goods":true,"src":"img/jp_glfs.png"});
							break;
						case obj[3].id:
							this.rotateFunc(obj[3].id, 180,{"title":"美的榨汁机","goods":true,"src":"img/jp_mdzjj.png"});
							break;
						case obj[4].id:
							this.rotateFunc(obj[4].id, 216,{"title":"58元现金红包","goods":false,"src":"img/xjhb_58.png"});
							break;
						case obj[5].id:
							this.rotateFunc(obj[5].id, 324,{"title":"18元现金红包","goods":false,"src":"img/xjhb_18.png"});
							break;
						case obj[6].id:
							this.rotateFunc(obj[6].id, 36, {"title":"50元投资红包","goods":false,"src":"img/tzhb_50.png"});
							break;
						case obj[7].id:
							this.rotateFunc(obj[7].id, 108, {"title":"30元投资红包","goods":false,"src":"img/tzhb_30.png"});
							break;
						case obj[8].id:
							this.rotateFunc(obj[8].id, 144,{"title":"20元投资红包","goods":false,"src":"img/tzhb_20.png"});
							break;
						case obj[9].id:
							this.rotateFunc(obj[9].id, 252,{"title":"8元投资红包","goods":false,"src":"img/tzhb_8.png"});
							break;
						default:
							throw "id错误"
					}
				},
				init:function(){//初始化
					this.getPlaynum();
					$("#start").click(function() {
						var _this=$(this);
						if(times < 20180620 ){
							return 
						}else if(times > 20180622){
							return 
						}else{
							if(!useCode){
								return
							}
							if(luckDraw.isture) return; // 如果在执行就退出
						}
//						if(luckDraw.playnum <= 0) { //当抽奖次数为0的时候执行
//							$(this).attr("src","img/qtz.png")
//							luckDraw.isture = false;
//							$(this).unbind("click");
//							$(this).click(function(){
//								wv.go(1);
//							})							
//						}else{
							getData({
								"url":location.origin + "/LuckSys",
								"code":"190190"
							},function(data){
								luckDraw.isture = true; // 标志为 在执行
								luckDraw.playnum=data.remainChance;
								$('.luckDrawTimes p span').html(luckDraw.playnum);//次数显示为0
								luckDraw.clickfunc(data.prizeId,luckDraw.priceList);
							})
//						}
						
					})
					
				},
				rotateFunc:function(awards, angle, data){
					this.isture = true;
					this.$btn.stopRotate();
					this.$btn.rotate({
						angle: 0, //旋转的角度数
						duration: 4000, //旋转时间
						animateTo: angle + 1440, //给定的角度,让它根据得出来的结果加上1440度旋转
						callback: function() {
							luckDraw.isture = false; // 标志为 执行完毕
							var zjBox=$(".zjBox");
							$(".zjBox .rewardPic").children().attr("src",data.src)
							$(".textBtn span").html(data.title)
							if(data.goods){
								$(".pTitle").html("工作人员会在3个工作日内与您取得联系")
							}else{
								$(".pTitle").html("请在[资产-我的优惠券]中查看")
							}
							zjBox.fadeIn();
							if(luckDraw.playnum<=0){
								$("#start").attr("src","img/qtz.png")
								$("#start").unbind("click");
								$("#start").click(function(){
									wv.go(1);
								})
							}
						}
					})
				}
			}
			$(".textBtn button").click(function(){
				$(this).parent().parent().parent().fadeOut();
			})
			
			function getTime(){
				var myDate = new Date(),
					year = myDate.getFullYear(),
					month = (myDate.getMonth() + 1) < 10 ? "0" + (myDate.getMonth() + 1) : (myDate.getMonth() + 1),
					da = myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate();
				times = year + month + da;
				return times
			}
			function layoutInit() {
				var html = '<div class="fullRaise"><div>' +
					'<img style="width:65px;display: inline-block;margin-top: 20px;margin-left: 25px;height: auto;"  src="img/jxq.png"/>' +
					'<img style="float: right;width: 65px;z-index: 50;position: relative;margin-right: 40px;height: auto;" src="img/jsrw.png"/>' +
					'</div><div class="raisesBox"><h2></h2><ul>' +
					'<li class="raises">' +
					'<p style="flex: auto;">7.5<span class="bfh">%</span><span>+1.8<span class="bfh">%</span></span></p>' +
					'<p class="yyz item">月月赚<span>6.18</span><br />30天</p>' +
					'<button class="item" type="button">立即投资</button>' +
					'</li><li class="raises" style="background: #fff;">' +
					'<p style="flex: auto;">9.0<span class="bfh">%</span><span>+1.8<span class="bfh">%</span></span></p>' +
					'<p class="yyz item">月月赚<span>6.18</span><br />30天</p>' +
					'<button class="item" type="button">立即投资</button>' +
					'</li><li class="raises">' +
					'<p style="flex: auto;letter-spacing:-0.1rem;">11.0<span class="bfh">%</span><span class="pfont">+1.8<span class="bfh">%</span></span></p>' +
					'<p class="yyz item">月月赚<span>6.18</span><br />30天</p>' +
					'<button class="item" type="button">立即投资</button>' +
					'</li></ul>' +
					'</div></div>';
					console.log(times);
				var cond=$(".conducting"),
					start=$("#start"),
					lDraw=$("#luckDraw");
				if(times >= 20180615 && times <= 20180619) {//全场加薪活动进行中
					
					$(cond[0]).addClass("nostarted").html("未开始");
					$(cond[1]).removeClass("nostarted").html("进行中");
					lDraw.before(html);
					start.attr("src","img/cjwks.png")
					$("button").click(function(){
						wv.go(1);
					});
				}else if(times >= 20180620 && times <= 20180622){//抽奖活动进行中
					$(cond[0]).removeClass("nostarted").html("进行中");
					$(cond[1]).addClass("nostarted").html("已结束");
					if(luckDraw.playnum <= 0){
						start.attr("src","img/qtz.png")
						start.unbind("click");
						start.click(function(){
							wv.go(1)
						})
					}else{
						start.attr("src","img/cjks.png")
					}
					lDraw.after(html);
					var btn=$("button.item");
					for (var i=0;i<btn.length;i++) {
						$(btn[i]).html("已结束").css("background","#979797")
					}
				}else if(times >= 20180623){//活动已结束
					$(cond[0]).addClass("nostarted").html("已结束");
					$(cond[1]).addClass("nostarted").html("已结束");
					start.attr("src","img/hdyjs.png");
					lDraw.after(html);
					var btn=$("button.item");
					for (var i=0;i<btn.length;i++) {
						$(btn[i]).html("已结束").css("background","#979797")
					}
				}else{
					lDraw.before(html);
					var btn=$("button.item");
					for (var i=0;i<btn.length;i++) {
						$(btn[i]).html("未开始").css("background","#979797")
					}
				}

			}

			function wrap() { //跑马灯
				var csp=document.getElementById("CText");
				getData({
					"url":location.origin + "/LuckSys",
					"code":"190224",
				},function(data){
					var innerp = $(".innerp"),
						html = "",dataLen=data.length;
					for(var i=0;i<dataLen;i++){
						html += "<span>" + data[i] + "</span>";
					}
					innerp.append(html);
					csp.style.cssText="-webkit-animation-duration:"+ dataLen * 5 + "s",
					innerp.css({
							"width":(dataLen * 230 + 5 * dataLen) + "px",
							"-webkit-animation-duration": dataLen * 5 + "s",
							"animation-duration": dataLen * 5 + "s"
						})
					if(dataLen==20){
						setTimeout(function(){
							innerp.html("");
							wrap()
						},100000)
					}
				})
			}

			function rewardExplain() { //奖励说明
				$(".rewardB").fadeIn();
				$(".rewardB>img").eq(1).one("click", function() {
					$(this).parent().fadeOut();
				})
			}

			function myPrize() { //我的奖品
				if(!useCode){
					return layer.open({
						content: "您还未登录！",
						skin: 'msg',
						time: 2,
					})
				}
				getData({
					"url":location.origin + "/LuckSys",
					"code":"190210"
				},function(data){
					var list=data,
						html='<tr><td class="zjbtn"><span>奖品</span></td>'+
							'<td class="zjbtn"><span>数量</span></td></tr>';
					if(list.length>0){
						$(".zjjl table tbody").html("");
						for (var i=0;i<list.length;i++) {
							html+='<tr><td>'+list[i].prizeName+'</td>'+
								'<td>'+list[i].count+'</td></tr>';
						}
						$(".zjjl table").append(html);
						$(".zjjl").show();
						$(".kong").hide();
					}else{
						$(".zjjl").hide();
						$(".kong").show();
					}
					$(".myPrize").fadeIn();
					$(".Dclose img").one("click", function() {
						$(this).parent().parent().fadeOut();
					})
				})
			}
			function getData(obje,callback){
				var body={
					"userCode":useCode
				}
				body=$.extend({},body,obje.body);
				var obj={
					"header":reqHead(obje.code),
					"body":body
				}
				$.ajax({
					type:"post",
					url:obje.url,
/*					url:"http://114.55.5.66:10030/beikbank-activity-api/activityApi.do",*/
					dataType:"json",
					data:{
						"report":JSON.stringify(yanqian(obj))
					},
					success:function(data){
						console.log(data)
						if(data.header.re_code==="0000"){
							callback(data.body) 
						}else{
							return layer.open({
								content: data.header.re_msg,
								skin: 'msg',
								time: 2,
							})							
						}
					},
					error:function(err){
						console.log(err.statusText)
					}
				});
			}
		</script>
	</body>

</html>